package com.hgm.study.ui.components


import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.unit.dp
import com.hgm.study.viewmodel.TaskViewModel

@Composable
fun CircleRing(boxWidthDp: Int,taskVM:TaskViewModel) {

      val strokeWidth = 30f

      Canvas(modifier = Modifier.size(boxWidthDp.dp)) {
            //两种实现进度条旋转的方案：
            //1、可以在外面套一层 rotate，实现旋转
            //2、直接调整startAngle和sweepAngle的值
            //rotate(180f){
            //      drawArc(
            //            Color(0, 0, 0, 15),
            //            startAngle = -10f,
            //            sweepAngle = 200f,
            //            useCenter = false,
            //            style = Stroke(30f, cap = StrokeCap.Round)
            //      )
            //}
            drawArc(
                  Color(0, 0, 0, 15),
                  startAngle = 160f,
                  sweepAngle = 220f,
                  useCenter = false,
                  style = Stroke(strokeWidth, cap = StrokeCap.Round)
            )

            drawArc(
                  Color.White,
                  startAngle = 160f,
                  sweepAngle = taskVM.pointOfYearPercent,
                  useCenter = false,
                  style = Stroke(strokeWidth, cap = StrokeCap.Round)
            )
      }

}


